package org.geektimes.configuration.microprofile.config.source;

import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
import org.eclipse.microprofile.config.spi.ConfigSource;

import java.util.HashMap;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.Set;

public class MyConfigSource implements ConfigSource {

    private final Map<String, String> properties;

    public MyConfigSource() {
        Map systemProperties = System.getProperties();
        this.properties = new HashMap<>(systemProperties);
    }

    @Override
    public Set<String> getPropertyNames() {
        return null;
    }

    @Override
    public String getValue(String s) {
        return null;
    }

    @Override
    public String getName() {
        return null;
    }

    public static void main(String[] args) {
        System.out.println(new HashMap<>(System.getProperties()));
        ServiceLoader<MyConfigSource> myConfigSources = ServiceLoader.load(MyConfigSource.class);
        System.out.println(myConfigSources);
        Config config = ConfigProvider.getConfig();
        Iterable<ConfigSource> configSources = config.getConfigSources();
        System.out.println(configSources);
    }
}
